//package com.xiguaji.tiktok.task.blogger_test.repository;
//
//import com.xiguaji.tiktok.task.blogger_test.Demo;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.core.BatchPreparedStatementSetter;
//import org.springframework.jdbc.core.BeanPropertyRowMapper;
//import org.springframework.jdbc.core.JdbcTemplate;
//
//import java.sql.PreparedStatement;
//import java.sql.SQLException;
//import java.sql.Timestamp;
//import java.util.List;
//
//public class DemoExtRepositoryImpl implements DemoExtRepository {
//    @Autowired
//    JdbcTemplate jdbcTemplate;
//
//    public List<Demo> customerMethod() {
//        return jdbcTemplate.query("select * from blogger", new BeanPropertyRowMapper<>(Demo.class));
//    }
//
//    public void batchInsert(List<Demo> demos) {
//        jdbcTemplate.batchUpdate("insert into blogger (name,register_time,is_enable) values(?,?,?)", new BatchPreparedStatementSetter() {
//            @Override
//            public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
//                preparedStatement.setString(1, demos.get(i).getName());
//                preparedStatement.setTimestamp(2, new Timestamp(demos.get(i).getRegister_time()));
//                preparedStatement.setBoolean(3, demos.get(i).is_enable());
//            }
//
//            @Override
//            public int getBatchSize() {
//                return demos.size();
//            }
//        });
//    }
//}